def ispalindrom(n):
    nstring = str(n)
    length = len(nstring)
    if not length & 1:
        mid = length / 2
        first = nstring[:mid]
        last = nstring[mid:]
        rlast = last[::-1]
        if first == rlast:
            return True
        return False
    else:
        mid = length / 2
        first = nstring[:mid]
        last = nstring[mid+1:]
        rlast = last[::-1]
        if first == rlast:
            return True
        return False




num = 9009
if ispalindrom(num):
    print str(9009) + " is a palindrom"
else:
    print str(9009) + " is not a palindrom"


num1 = 999
num2 = 999
flag = True
largest = 0
while flag:
    if num1 == 100:
        flag = False
    if num2 == 100:
        num1 -= 1
        num2 = num1
    x = num1 * num2
    #print str(num1) + " and " + str(num2) + " = " + str(x)
    if ispalindrom(x):
        #flag = False
        print "answer: " + str(num1) + " and " + str(num2) + " = " + str(x)
        if x >= largest:
	    largest = x
	    print "largest: " + str(largest)
    num2 -= 1

print "largest palindrom is: " + str(largest)